import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBJsonToModel/YBMineModel/YBMessageModel.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBMineModule/YBMessagePage/YBMessageSubPage.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBMineModule/YBMineProvider/YBMineMessageProvider.dart';

class YBMessageMainPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
        child: Scaffold(
          appBar: AppBar(
            elevation: 0,
            title: Text(YBChineseText.mineMyMessageTitle,style: YBTextStyle.TextStyle30313320Medium),
          ),
          body: ChangeNotifierProvider(
              create:(context) => YBMineMessageProvider()..getMessageInfoData(),
              child: Consumer<YBMineMessageProvider>(
                  builder: (context,messageInfo,child){
                    return SmartRefresher(
                      controller:messageInfo.easyRefresh,
                      onRefresh: () async {
                        messageInfo.getMessageInfoData();
                      },
                      child: CustomScrollView(
                        slivers: [
                          SliverList(
                            delegate: SliverChildBuilderDelegate((_,int index){
                              YBMessageModel yiJiModel = messageInfo.mineMessageModelList[index];
                              return YBMessageSubPage(title: yiJiModel.title,message: yiJiModel.message,createTime: yiJiModel.createTime,);
                            },
                              childCount: messageInfo.mineMessageModelList.length,
                            ),
                          ),
                        ],
                      ),
                    );
                  }
              ),
          ),
        ),
    );
  }
}
